import java.util.Random;
import java.util.Scanner;

public class App {
    public static void main(String[] args) throws Exception {
        //设置所需函数
        Random r = new Random();
        Scanner sc = new Scanner(System.in);
        //初始化所需变量
        String[] words = new String[30];//被替换字母集
        int i = 0;//循环计数器
        int j = 0;
        char ch = '0';//随机字符接收器
        String arr = "";//原字符串
        String password = "";//被替换字符构成的字符串
        String str2 = "";//和谐后的字符串
        //开始
        System.out.print("\n请输入违禁字母: ");
        password = sc.nextLine();
        //将字符串转换为字母集
        for(i = 0;i < password.length();i++)
        {
            words[i] = "" + password.charAt(i);
        }
        //生成原字符串
        for(i = 0;i < 40;i++)
        {
            j = r.nextInt(2);
            ch = (j == 1) ? (char)(r.nextInt(26) + 'a') :  (char)(r.nextInt(26) + 'A');
            arr += ch;
        }
        System.out.printf("\nstr1 = [ %s ]\n",arr);
        //替换违禁字母
        str2 = arr;
        for(i = 0;i < words.length;i++)
        {
            if(words[i] == null)//如果违禁字符检查完毕，退出和谐程序
            {
                break;
            }
            str2 = str2.replace(words[i],"*");//替换违禁字符
        }
        System.out.printf("\nstr2 = [ %s ]\n",str2);
    }
}
